home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-04d.zip / 04d / CHIP / Porady / Niewidoczny w sieci / TOR 0.1.2.7 / vidalia-bundle-0.1.2.7-alpha-0.0.10.exe / Tor / Documents / HACKING < prev    next >
Text File  |  2007-02-07  |  4KB  |  113 lines

  1.  
  2. 0. The buildbot.
  3.  
  4.   http://tor-buildbot.freehaven.net:8010/
  5.  
  6. 1. Coding conventions
  7.  
  8. 1.1. Details
  9.  
  10.   Use tor_malloc, tor_free, tor_snprintf, tor_strdup, and tor_gettimeofday
  11.   instead of their generic equivalents.  (They always succeed or exit.)
  12.  
  13.   You can get a full list of the compatibility functions that Tor provides
  14.   by looking through src/common/util.h and src/common/compat.h.
  15.  
  16.   Use 'INLINE' instead of 'inline', so that we work properly on Windows.
  17.  
  18. 1.2. Calling and naming conventions
  19.  
  20.   Whenever possible, functions should return -1 on error and 0 on success.
  21.  
  22.   For multi-word identifiers, use lowercase words combined with
  23.   underscores. (e.g., "multi_word_identifier").  Use ALL_CAPS for macros and
  24.   constants.
  25.  
  26.   Typenames should end with "_t".
  27.  
  28.   Function names should be prefixed with a module name or object name.  (In
  29.   general, code to manipulate an object should be a module with the same
  30.   name as the object, so it's hard to tell which convention is used.)
  31.  
  32.   Functions that do things should have imperative-verb names
  33.   (e.g. buffer_clear, buffer_resize); functions that return booleans should
  34.   have predicate names (e.g. buffer_is_empty, buffer_needs_resizing).
  35.  
  36. 1.3. What To Optimize
  37.  
  38.   Don't optimize anything if it's not in the critical path.  Right now,
  39.   the critical path seems to be AES, logging, and the network itself.
  40.   Feel free to do your own profiling to determine otherwise.
  41.  
  42. 1.4. Log conventions
  43.  
  44.   http://wiki.noreply.org/noreply/TheOnionRouter/TorFAQ#LogLevels
  45.  
  46.   No error or warning messages should be expected during normal OR or OP
  47.   operation.
  48.  
  49.   If a library function is currently called such that failure always
  50.   means ERR, then the library function should log WARN and let the caller
  51.   log ERR.
  52.  
  53.   [XXX Proposed convention: every message of severity INFO or higher should
  54.   either (A) be intelligible to end-users who don't know the Tor source; or
  55.   (B) somehow inform the end-users that they aren't expected to understand
  56.   the message (perhaps with a string like "internal error").  Option (A) is
  57.   to be preferred to option (B). -NM]
  58.  
  59. 1.5. Doxygen
  60.  
  61.   We use the 'doxygen' utility to generate documentation from our
  62.   source code. Here's how to use it:
  63.  
  64.   1. Begin every file that should be documented with
  65.          /**
  66.           * \file filename.c
  67.           * \brief Short desccription of the file.
  68.           **/
  69.  
  70.      (Doxygen will recognize any comment beginning with /** as special.)
  71.  
  72.   2. Before any function, structure, #define, or variable you want to
  73.      document, add a comment of the form:
  74.  
  75.         /** Describe the function's actions in imperative sentences.
  76.          *
  77.          * Use blank lines for paragraph breaks
  78.          *   - and
  79.          *   - hyphens
  80.          *   - for
  81.          *   - lists.
  82.          *
  83.          * Write <b>argument_names</b> in boldface.
  84.          *
  85.          * \code
  86.          *     place_example_code();
  87.          *     between_code_and_endcode_commands();
  88.          * \endcode
  89.          */
  90.  
  91.   3. Make sure to escape the characters "<", ">", "\", "%" and "#" as "\<",
  92.      "\>", "\\", "\%", and "\#".
  93.  
  94.   4. To document structure members, you can use two forms:
  95.  
  96.        struct foo {
  97.          /** You can put the comment before an element; */
  98.          int a;
  99.          int b; /**< Or use the less-than symbol to put the comment
  100.                  * after the element. */
  101.        };
  102.  
  103.   5. To generate documentation from the Tor source code, type:
  104.  
  105.      $ doxygen -g
  106.  
  107.      To generate a file called 'Doxyfile'.  Edit that file and run
  108.      'doxygen' to generate the API documentation.
  109.  
  110.   6. See the Doxygen manual for more information; this summary just
  111.      scratches the surface.
  112.  
  113.